/**
 * Author@ Cheng Feitian
 * Date: 2020-3-17
 * Description: 根据输入的日期，计算是这一年的第几天。。
 * 测试用例有多组，注意循环输入
 * Input Format: 输入多行，每行空格分割，分别是年，月，日
 * Output Format: 成功:返回outDay输出计算后的第几天;
 *                失败:返回-1
 */

#include <stdio.h>

const int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int convert(int *nYear, int *nMonth, int *nDay);

int main(void)
{
    /* 初始化 */
    int result = 0;
    int nYear, nMonth, nDay;
    /* 主逻辑 */
    while (scanf("%d %d %d", &nYear, &nMonth, &nDay) != EOF)
    {
        result = convert(&nYear, &nMonth, &nDay);
        printf("%d\n", result);
    }
    return 0;
}

int convert(int *nYear, int *nMonth, int *nDay)
{
    int result = 0;
    int flag = 0;
    if (*nYear > 0 && *nMonth > 0 && *nDay > 0)
    {
        if ((*nYear % 4 == 0 && *nYear % 100 != 0) || *nYear % 400 == 0)
        {
            flag = 1;
        }
        else
        {
            flag = 0;
        }
        for (int i = 0; i < *nMonth; i++)
        {
            result += month[i];
            if (i == 2 && flag)
            {
                result++;
            }
        }
        result += *nDay;
    }
    else
        result = -1;
    return result;
}
